#![allow(dead_code, mutable_transmutes, non_camel_case_types, non_snake_case, non_upper_case_globals, unused_assignments, unused_mut)]
extern crate libc;
use primary::alloc_testing::*;
use primary::compare_pointer::*;
use primary::compare_string::*;
use primary::compare_int::*;
use primary::hash_pointer::*;
use primary::hash_string::*;
use primary::hash_int::*;
extern "C" {
    fn __assert_fail(
        __assertion: *const libc::c_char,
        __file: *const libc::c_char,
        __line: libc::c_uint,
        __function: *const libc::c_char,
    ) -> !;
                                    }
#[no_mangle]
pub extern "C" fn test_int_compare() {
    let mut a: libc::c_int = 4;
    let mut b: libc::c_int = 8;
    let mut c: libc::c_int = 4;

    assert!(int_compare(
        &mut a as *mut libc::c_int as *mut libc::c_void,
        &mut b as *mut libc::c_int as *mut libc::c_void,
    ) < 0, "int_compare(&a, &b) < 0");
    assert!(int_compare(
        &mut b as *mut libc::c_int as *mut libc::c_void,
        &mut a as *mut libc::c_int as *mut libc::c_void,
    ) > 0, "int_compare(&b, &a) > 0");
    assert!(int_compare(
        &mut a as *mut libc::c_int as *mut libc::c_void,
        &mut c as *mut libc::c_int as *mut libc::c_void,
    ) == 0, "int_compare(&a, &c) == 0");
}
#[no_mangle]
pub extern "C" fn test_int_equal() {
    let mut a: libc::c_int = 4;
    let mut b: libc::c_int = 8;
    let mut c: libc::c_int = 4;

    assert_ne!(
        int_equal(
            &mut a as *mut libc::c_int as *mut libc::c_void,
            &mut c as *mut libc::c_int as *mut libc::c_void,
        ),
        0,
        "int_equal(&a, &c) != 0"
    );
    assert_eq!(
        int_equal(
            &mut a as *mut libc::c_int as *mut libc::c_void,
            &mut b as *mut libc::c_int as *mut libc::c_void,
        ),
        0,
        "int_equal(&a, &b) == 0"
    );
}
#[no_mangle]
pub extern "C" fn test_pointer_compare() {
    let mut array: [libc::c_int; 5] = [0; 5];

    unsafe {
        let ptr0 = array.as_mut_ptr().offset(0);
        let ptr4 = array.as_mut_ptr().offset(4);
        let ptr3 = array.as_mut_ptr().offset(3);
        let ptr2 = array.as_mut_ptr().offset(2);

        assert!(
            pointer_compare(
                &mut *ptr0 as *mut libc::c_int as *mut libc::c_void,
                &mut *ptr4 as *mut libc::c_int as *mut libc::c_void,
            ) < 0,
            "pointer_compare(&array[0], &array[4]) < 0"
        );
        assert!(
            pointer_compare(
                &mut *ptr3 as *mut libc::c_int as *mut libc::c_void,
                &mut *ptr2 as *mut libc::c_int as *mut libc::c_void,
            ) > 0,
            "pointer_compare(&array[3], &array[2]) > 0"
        );
        assert!(
            pointer_compare(
                &mut *ptr4 as *mut libc::c_int as *mut libc::c_void,
                &mut *ptr4 as *mut libc::c_int as *mut libc::c_void,
            ) == 0,
            "pointer_compare(&array[4], &array[4]) == 0"
        );
    }
}
#[no_mangle]
pub extern "C" fn test_pointer_equal() {
    let mut a: libc::c_int = 0;
    let mut b: libc::c_int = 0;

    assert_ne!(
        pointer_equal(
            &mut a as *mut libc::c_int as *mut libc::c_void,
            &mut a as *mut libc::c_int as *mut libc::c_void,
        ),
        0,
        "pointer_equal(&a, &a) != 0"
    );
    assert_eq!(
        pointer_equal(
            &mut a as *mut libc::c_int as *mut libc::c_void,
            &mut b as *mut libc::c_int as *mut libc::c_void,
        ),
        0,
        "pointer_equal(&a, &b) == 0"
    );
}
#[no_mangle]
pub extern "C" fn test_string_compare() {
    let mut test1: [libc::c_char; 6] = unsafe {
        *::core::mem::transmute::<&[u8; 6], &mut [libc::c_char; 6]>(b"Apple\0")
    };
    let mut test2: [libc::c_char; 7] = unsafe {
        *::core::mem::transmute::<&[u8; 7], &mut [libc::c_char; 7]>(b"Orange\0")
    };
    let mut test3: [libc::c_char; 6] = unsafe {
        *::core::mem::transmute::<&[u8; 6], &mut [libc::c_char; 6]>(b"Apple\0")
    };

    assert!(
        string_compare(
            test1.as_mut_ptr() as *mut libc::c_void,
            test2.as_mut_ptr() as *mut libc::c_void,
        ) < 0,
        "string_compare(test1, test2) < 0"
    );
    assert!(
        string_compare(
            test2.as_mut_ptr() as *mut libc::c_void,
            test1.as_mut_ptr() as *mut libc::c_void,
        ) > 0,
        "string_compare(test2, test1) > 0"
    );
    assert!(
        string_compare(
            test1.as_mut_ptr() as *mut libc::c_void,
            test3.as_mut_ptr() as *mut libc::c_void,
        ) == 0,
        "string_compare(test1, test3) == 0"
    );
}
#[no_mangle]
pub extern "C" fn test_string_equal() {
    let mut test1: [libc::c_char; 22] = unsafe {
        *::core::mem::transmute::<&[u8; 22], &mut [libc::c_char; 22]>(b"this is a test string\0")
    };
    let mut test2: [libc::c_char; 23] = unsafe {
        *::core::mem::transmute::<&[u8; 23], &mut [libc::c_char; 23]>(b"this is a test string \0")
    };
    let mut test3: [libc::c_char; 21] = unsafe {
        *::core::mem::transmute::<&[u8; 21], &mut [libc::c_char; 21]>(b"this is a test strin\0")
    };
    let mut test4: [libc::c_char; 22] = unsafe {
        *::core::mem::transmute::<&[u8; 22], &mut [libc::c_char; 22]>(b"this is a test strinG\0")
    };
    let mut test5: [libc::c_char; 22] = unsafe {
        *::core::mem::transmute::<&[u8; 22], &mut [libc::c_char; 22]>(b"this is a test string\0")
    };

    unsafe {
        assert_ne!(
            string_equal(
                test1.as_mut_ptr() as *mut libc::c_void,
                test5.as_mut_ptr() as *mut libc::c_void,
            ),
            0
        );
        assert_eq!(
            string_equal(
                test1.as_mut_ptr() as *mut libc::c_void,
                test2.as_mut_ptr() as *mut libc::c_void,
            ),
            0
        );
        assert_eq!(
            string_equal(
                test1.as_mut_ptr() as *mut libc::c_void,
                test3.as_mut_ptr() as *mut libc::c_void,
            ),
            0
        );
        assert_eq!(
            string_equal(
                test1.as_mut_ptr() as *mut libc::c_void,
                test4.as_mut_ptr() as *mut libc::c_void,
            ),
            0
        );
    }
}
#[no_mangle]
pub extern "C" fn test_string_nocase_compare() {
    let test1: [libc::c_char; 6] = unsafe {
        *::core::mem::transmute::<&[u8; 6], &[libc::c_char; 6]>(b"Apple\0")
    };
    let test2: [libc::c_char; 7] = unsafe {
        *::core::mem::transmute::<&[u8; 7], &[libc::c_char; 7]>(b"Orange\0")
    };
    let test3: [libc::c_char; 6] = unsafe {
        *::core::mem::transmute::<&[u8; 6], &[libc::c_char; 6]>(b"Apple\0")
    };
    let test4: [libc::c_char; 6] = unsafe {
        *::core::mem::transmute::<&[u8; 6], &[libc::c_char; 6]>(b"Alpha\0")
    };
    let test5: [libc::c_char; 6] = unsafe {
        *::core::mem::transmute::<&[u8; 6], &[libc::c_char; 6]>(b"bravo\0")
    };
    let test6: [libc::c_char; 8] = unsafe {
        *::core::mem::transmute::<&[u8; 8], &[libc::c_char; 8]>(b"Charlie\0")
    };

    unsafe {
        assert!(
            string_nocase_compare(
                test1.as_ptr() as *mut libc::c_void,
                test2.as_ptr() as *mut libc::c_void,
            ) < 0,
            "string_nocase_compare(test1, test2) < 0"
        );
        assert!(
            string_nocase_compare(
                test2.as_ptr() as *mut libc::c_void,
                test1.as_ptr() as *mut libc::c_void,
            ) > 0,
            "string_nocase_compare(test2, test1) > 0"
        );
        assert!(
            string_nocase_compare(
                test1.as_ptr() as *mut libc::c_void,
                test3.as_ptr() as *mut libc::c_void,
            ) == 0,
            "string_nocase_compare(test1, test3) == 0"
        );
        assert!(
            string_nocase_compare(
                test4.as_ptr() as *mut libc::c_void,
                test5.as_ptr() as *mut libc::c_void,
            ) < 0,
            "string_nocase_compare(test4, test5) < 0"
        );
        assert!(
            string_nocase_compare(
                test5.as_ptr() as *mut libc::c_void,
                test6.as_ptr() as *mut libc::c_void,
            ) < 0,
            "string_nocase_compare(test5, test6) < 0"
        );
    }
}
#[no_mangle]
pub extern "C" fn test_string_nocase_equal() {
    let mut test1: [libc::c_char; 22] = unsafe {
        *::core::mem::transmute::<&[u8; 22], &mut [libc::c_char; 22]>(b"this is a test string\0")
    };
    let mut test2: [libc::c_char; 23] = unsafe {
        *::core::mem::transmute::<&[u8; 23], &mut [libc::c_char; 23]>(b"this is a test string \0")
    };
    let mut test3: [libc::c_char; 21] = unsafe {
        *::core::mem::transmute::<&[u8; 21], &mut [libc::c_char; 21]>(b"this is a test strin\0")
    };
    let mut test4: [libc::c_char; 22] = unsafe {
        *::core::mem::transmute::<&[u8; 22], &mut [libc::c_char; 22]>(b"this is a test strinG\0")
    };
    let mut test5: [libc::c_char; 22] = unsafe {
        *::core::mem::transmute::<&[u8; 22], &mut [libc::c_char; 22]>(b"this is a test string\0")
    };

    assert_ne!(
        string_nocase_equal(
            test1.as_mut_ptr() as *mut libc::c_void,
            test5.as_mut_ptr() as *mut libc::c_void,
        ),
        0,
        "string_nocase_equal(test1, test5) != 0"
    );
    assert_eq!(
        string_nocase_equal(
            test1.as_mut_ptr() as *mut libc::c_void,
            test2.as_mut_ptr() as *mut libc::c_void,
        ),
        0,
        "string_nocase_equal(test1, test2) == 0"
    );
    assert_eq!(
        string_nocase_equal(
            test1.as_mut_ptr() as *mut libc::c_void,
            test3.as_mut_ptr() as *mut libc::c_void,
        ),
        0,
        "string_nocase_equal(test1, test3) == 0"
    );
    assert_ne!(
        string_nocase_equal(
            test1.as_mut_ptr() as *mut libc::c_void,
            test4.as_mut_ptr() as *mut libc::c_void,
        ),
        0,
        "string_nocase_equal(test1, test4) != 0"
    );
}
